package com.zh.impl;

import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
import com.zh.constants.Constants;
import com.zh.pojo.domain.CustomerFine;
import com.zh.remote.api.CustomerApi;
import com.zh.result.JSONResult;
import com.zh.service.ICustomerFineService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.RestController;

import java.util.List;

/**
 * 远程调用loginApi对象 ，并实现LoginApi接口
 */
@RestController
public class RemoteCustomerApiImpl implements CustomerApi {
    @Autowired
    private ICustomerFineService customerFineService;


    /**
     * 查询乘客罚款记录
     * @param customerId 乘客Id
     * @return
     */
    @Override
    public JSONResult<Boolean> customerHasFine(Long customerId) {
        List<CustomerFine> list = customerFineService.list(new LambdaQueryWrapper<CustomerFine>()
                .eq(CustomerFine::getCustomerId, customerId)
                .eq(CustomerFine::getStatus, Constants.Customer.FINE_STATUS_UNPAID)); // 未缴纳的 信息
        return JSONResult.success(list.size() > 0);
    }
}
